<template>
<div class="box-2">
    <h3>孙组件</h3>
    <p>获取参数：{{ a  }}</p>
    <p>获取汽车：{{ c }}</p>
    <el-button type="success" @click="updateData">调用方法</el-button>
    <el-button type="success" @click="earn">调用注入方法</el-button>
</div>
</template>

<script lang="ts" setup name="Grandson">
import { inject } from 'vue';



let {a, earn} = inject('assets', {a:0,earn:()=>{}})
let c = inject('carinfo', {name:'未知',price:0})
function updateData(){
    c.name = "奥迪"
}
</script>

<style scoped>
.box-2{
    background-color: rgb(163, 55, 154);
    padding: 20px;
    border-radius: 10px;
}
</style>